ServerEvents.recipes((event) => {
    let RegisteredFormula = (fluid) => {
        event.recipes.custommachinery.custom_machine("eou:oil_fired_generator/controller", 20)
            .priority(1)
            .requireStructure([[
                "A",
                "m"
            ]], {
                "A": "eou:oil_fired_generator/stress_port"
            })
            .requireFunctionToStart((ctx) => {
                let level = ctx.block.minecraftLevel
                let pos = ctx.block.getPos()
                let facing = ctx.getBlock().getProperties().get("facing")
                //控制器其他机器相对坐标
                let ports_pos = { fuel: [0, 0, 0], exportation: [0, 0, -1] }
                let ports = global.getothermachine(pos, ports_pos, facing, level)
                if (ports["fuel"].getFluidStored("fluid1").getId() == fluid.getId()
                    && ports["fuel"].getFluidStored("fluid1").amount >= fluid.amount) {
                    ctx.machine.removeFluidFromTank("fluid1", fluid.amount, false)
                    return Result.success()
                }
                return Result.error("No fuel")
            })
            .requireFunctionEachTick((ctx) => {
                let level = ctx.block.minecraftLevel
                let pos = ctx.block.getPos()
                let facing = ctx.getBlock().getProperties().get("facing")
                //控制器其他机器相对坐标
                let ports_pos = { fuel: [0, 0, 0], exportation: [0, 0, -1] }
                let ports = global.getothermachine(pos, ports_pos, facing, level)
                if (ports["fuel"].getFluidStored("fluid1").getId() == fluid.getId()
                    && ports["fuel"].getFluidStored("fluid1").amount >= fluid.amount) {
                    ports["exportation"].data.work = 1
                    ctx.machine.removeFluidFromTank("fluid1", fluid.amount, false)
                    return Result.success()
                } else {
                    ports["exportation"].data.work = 0
                }
                return Result.error("No fuel")
            })
            .resetOnError()
            .jei()
            .produceSU(64, 16384)
            .requireFluidPerTick(fluid)
    }
    RegisteredFormula(Fluid.of("createindustry:naphtha", 50))
    RegisteredFormula(Fluid.of('immersivepetroleum:naphtha', 50))
    RegisteredFormula(Fluid.of('createindustry:kerosene', 40))
    RegisteredFormula(Fluid.of('immersivepetroleum:kerosene', 40))
    RegisteredFormula(Fluid.of('pneumaticcraft:kerosene', 40))
    RegisteredFormula(Fluid.of('createindustry:gasoline', 20))
    RegisteredFormula(Fluid.of('immersivepetroleum:gasoline', 20))
    RegisteredFormula(Fluid.of('pneumaticcraft:gasoline', 20))
    //无燃料时候配方
    event.recipes.custommachinery.custom_machine("eou:oil_fired_generator/controller", 20)
        .requireStructure([[
            "A",
            "m"
        ]], {
            "A": "eou:oil_fired_generator/stress_port"
        })
        .requireFunctionEachTick((ctx) => {
            let level = ctx.block.minecraftLevel
            let pos = ctx.block.getPos()
            let facing = ctx.getBlock().getProperties().get("facing")
            //控制器其他机器相对坐标
            let ports_pos = { fuel: [0, 0, 0], exportation: [0, 0, -1] }
            let ports = global.getothermachine(pos, ports_pos, facing, level)
            ports["exportation"].data.work = 0
            return Result.success()
        })
        .resetOnError()
})